import BaseCURDV2Api from '@/framework/infra/base/BaseCURDV2Api'

class CommentPageApi extends BaseCURDV2Api {
  constructor() {
    super('comment')
  }
  list(params) {
    const getParams = { ...params }
    Object.keys(getParams).forEach(key => {
      if (Array.isArray(getParams[key])) {
        getParams[key] = getParams[key].join(',')
      }
    })
    return this.formatData(getParams)
  }
  check(params) {
    return this.get('/check', params)
  }
  async formatData (getParams) {
   const result = await this.get('/list-page', getParams)
   console.log(result, 'result')
   return {
      ...result,
      records: result?.records?.map(v => ({ ...v, businessTypeLabel: businessTypeMap[v.businessType]})),
   }
  }
}
const businessTypeMap = {
  1: '玩转福田',
  2: '旅游攻略',
  3: '精彩活动',
  4: '港人资讯',
  5: '福田十景'
}

export const commentPageApi = new CommentPageApi()
